package com.e.dianshang.service.impl;

import com.alibaba.fastjson.JSON;
import com.e.dianshang.mapper.MyeyeMapper;
import com.e.dianshang.pojo.Myeye;
import com.e.dianshang.service.MyeyeService;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.Map;

@Data
@NoArgsConstructor
@Service("MyeyeService")
public class MyeyeServiceImpl implements MyeyeService {
    @Resource
    MyeyeMapper myeyeMapper;

//    @Override
//    public List<Map> selectMyeyeByOpenid(Map map) {
//        return myeyeMapper.selectMyeyeByOpenid(map);
//    }

    @Override
    public Integer deleteMyeye(Map map) {
        String goodsId = map.get("goodsId").toString();
        Example example=new Example(Myeye.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orLike("goodsId",goodsId);
        return myeyeMapper.deleteByExample(example);
    }

    @Override
    public Integer insertMyEye(Map map) {
        Myeye myeye = JSON.parseObject(JSON.toJSONString(map), Myeye.class);
        return myeyeMapper.insert(myeye);
    }
}